package com.qianyu.project.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.entity.TenderPurchasePlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qianyu.project.mapper.provider.gs.TenderPurchasePlanMapperProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * <p>
 * 招标采购计划 Mapper 接口
 * </p>
 *
 * @author gs
 * @since 2021-01-30
 */
@Repository
public interface TenderPurchasePlanMapper extends BaseMapper<TenderPurchasePlan> {

    /**
     * description: 查询分页数据 <br/>
     * author: gs   <br/>
     * date: 2021/2/1 <br/>
     * params: [page, params] <br/>
     * return: com.baomidou.mybatisplus.core.metadata.IPage<com.qianyu.project.entity.TenderPurchasePlan>
     */
    @SelectProvider(type = TenderPurchasePlanMapperProvider.class,method = "selectPageList")
    IPage<TenderPurchasePlan> selectPageList(IPage page, Map<String, String> params);

    /**
     * description: 查询最大编号 <br/>
     * author: gs   <br/>
     * date: 2021/2/1 <br/>
     * params: [] <br/>
     * return: java.lang.String
     */
    @Select("select max(id) from tender_purchase_plan where year(date)=year(curdate())")
    String selectMaxCode();

    @Select("select tpp.*,pi.project_name,pi.id as project_id from tender_purchase_plan tpp,project_info pi where tpp.pro_id=pi.id and tpp.id=#{value}")
    TenderPurchasePlan selectById(String id);
}
